﻿// -----------------------------------------------------------------------
// <copyright file="Overlay.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Cubezicles
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Graphics;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class Overlay : DrawableGameComponent
    {
        // Help message
        const string helpMessage = "Use arrow keys to pan \n + - to zoom \n < > to rotate";

        // Time display format
        const string timeFormat = "Time: {0:00}:{1:00}";

        private Game1 game1 { get { return (Game1)Game; } }

        public Overlay(Game1 game) : base(game) { }

        public override void Draw(GameTime gameTime)
        {
            game1.SpriteBatch.Begin(SpriteSortMode.Texture, BlendState.AlphaBlend);

            // cornsilk is apparently white?
            // Write user controls/instructions to the top right corner of screen
            game1.SpriteBatch.DrawString(game1.Fonts["status"], helpMessage, 
                new Vector2(625, 2), Color.Cornsilk);

            drawTimeBar(gameTime);
            game1.SpriteBatch.End();
            
            base.Draw(gameTime);
        }

        protected override void LoadContent()
        {
            base.LoadContent();
        }

        /// <summary>
        /// Draw the timer bar at the top of the screen
        /// </summary>
        /// <param name="gameTime">Time elapsed since last frame/beginning</param>
        private void drawTimeBar(GameTime gameTime)
        {
            //long timeToDisplay = gameTime.TotalGameTime.Ticks / 1800000;
            //secs += gameTime.ElapsedGameTime.Ticks * game1.timeSpeed ;

            long timeToDisplay = game1.time / 1800000;
            long hour = timeToDisplay / (60);
            long min = timeToDisplay % (60);

            var timeDisplay = string.Format(timeFormat, hour, min);

            game1.SpriteBatch.DrawString(game1.Fonts["status"], timeDisplay, 
                new Vector2(10, 5), Color.Turquoise);
        }
    }
}
